package mxm.amfire;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import me.yokeyword.fragmentation.SupportFragment;
import mxm.amfire.adapter.LogoInfoPagerFragmentAdapter;

/**
 * Created by zengpeijin on 2017/2/16.
 */

public class LogoInfoFragment extends SupportFragment{

    private View rootView;
    private ViewPager viewPager;
    private int position;
    private String []titles;
    private int res[];
    public static LogoInfoFragment newInstance(String[] names, int[] res,int postion) {
        LogoInfoFragment fragment = new LogoInfoFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("postion",postion);
        bundle.putIntArray("res",res);
        bundle.putStringArray("names",names);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle != null) {
            position = bundle.getInt("postion");
            titles=bundle.getStringArray("names");
            res=bundle.getIntArray("res");
        }
    }
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView=inflater.inflate(R.layout.fragment_logoinfo,container,false);
        initView();
        return rootView;
    }

    private void initView() {
        viewPager= (ViewPager) rootView.findViewById(R.id.viewPager);
        viewPager.setAdapter(new LogoInfoPagerFragmentAdapter(getChildFragmentManager(),titles,res));
        viewPager.setCurrentItem(position);
    }
}
